set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode='nonstrict';
set hive.exec.max.dynamic.partitions=400;
set hive.exec.max.dynamic.partitions.pernode=400;

    
insert overwrite table jms_dm.dm_sign_abnormal_summary_dt
select
    to_date(sign_first_time) as sign_time            --签收/出库时间
     ,sign_first_code         as sign_network_code    --签收/出库网点code
     ,sign_first_name         as sign_network_name   --签收/出库网点名称
     ,sys_regional_code       as sys_regional_code    --管理大区code
     ,sys_regional_name       as sys_regional_name    --管理大区名称
     ,franchisee_code         as franchisee_code      --签收/出库加盟商code
     ,franchisee_name         as franchisee_name      --签收/出库加盟商名称
     ,agent_code              as agent_code           --签收/出库代理区code
     ,agent_name              as agent_name           --签收/出库代理区名称
     ,count(waybill_no)       as sign_cnt             --签收/出库量
     ,count(case when if_fine = 1 then waybill_no end) as fine_cnt --罚款票数
     ,if_mail_network --是否转邮网点
     ,dt
from jms_dm.dm_waybill_sign_abnormal_detail_dt
where dt = '{{ execution_date | cst_ds }}'
  and sign_first_code is not null  --剔除网点为空的数据
  and substr(agent_name,0,1)  <> 'B'  --剔除百世代理区
group by dt
        ,to_date(sign_first_time)
        ,sign_first_code
        ,sign_first_name
        ,sys_regional_code
        ,sys_regional_name
        ,franchisee_code
        ,franchisee_name
        ,agent_code
        ,agent_name
        ,if_mail_network --是否转邮网点
distribute by dt;    
